package com.heima.admin.controller.v1;

import com.heima.admin.service.AdChannelService;
import com.heima.model.admin.dtos.AdChannelDto;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
public class AdChannelController {

    @Autowired
    AdChannelService adChannelService;

    @PostMapping("/save")
    @ApiOperation("保存频道")
    public ResponseResult saveChannel(@RequestBody AdChannelDto dto) {

        return adChannelService.saveChannel(dto);
    }

    @PostMapping("/update")
    @ApiOperation("修改频道")
    public ResponseResult updateChannel(@RequestBody AdChannelDto dto) {

        return adChannelService.updateChannel(dto);
    }

    @GetMapping("/del/{id}")
    @ApiOperation("删除频道")
    public ResponseResult deleteChannel(@PathVariable("id") Integer id) {

        return adChannelService.deleteChannel(id);
    }

    @PostMapping("/list")
    @ApiOperation("频道列表")
    public ResponseResult channelList(@RequestBody AdChannelDto dto) {

        return adChannelService.channelList(dto);
    }
}
